package com.hzhr.iot.user.service;

import com.hzhr.iot.core.annotation.ApiImplicitInternalParams;
import com.hzhr.iot.core.annotation.CygQuery;
import com.hzhr.iot.core.annotation.CygQuerys;
import com.hzhr.iot.core.annotation.CygService;
import com.hzhr.iot.core.constant.AccessModeEnum;
import com.hzhr.iot.core.constant.CommonOptions;
import com.hzhr.iot.core.exception.ServiceException;
import com.hzhr.iot.core.util.HzhrTypeUtil;
import com.hzhr.iot.login.sdk.model.userCard.UserCardModel;
import com.hzhr.iot.user.Global;
import com.hzhr.iot.user.constant.UserOptions;
import com.hzhr.iot.user.constant.UserOptionsName;
import com.hzhr.iot.user.constant.UserOptionsTypeName;
import com.hzhr.iot.user.constant.User_ErrorsEnum;
import com.hzhr.iot.user.convertor.custom.UserCustomConvertor;
import com.hzhr.iot.user.dao.UserDao;
import com.hzhr.iot.user.dao.UserInRoleDao;
import com.hzhr.iot.user.dao.helper.CompanyDaoHelper;
import com.hzhr.iot.user.dao.helper.DeptDaoHelper;
import com.hzhr.iot.user.dao.helper.UserDaoHelper;
import com.hzhr.iot.user.dao.helper.UserInRoleDaoHelper;
import com.hzhr.iot.user.entity.CompanyEntity;
import com.hzhr.iot.user.entity.DeptEntity;
import com.hzhr.iot.user.entity.UserEntity;
import com.hzhr.iot.user.entity.UserInRoleEntity;
import com.hzhr.iot.user.entity.ext.UserEntityExt;
import com.hzhr.iot.user.model.user_sysInfo.User_SysInfoGetModel;
import com.hzhr.iot.user.model.user_sysInfo.User_SysInfoModel;
import com.hzhr.iot.user.model.user_sysInfo.User_SysInfoPutModel;
import com.hzhr.iot.user.queryModel.custom.UserCustomQueryModel;
import com.hzhr.iot.user.service.base.BaseService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.Date;
import java.util.List;
import java.util.Map;

@Service
@CygService(entity = UserEntity.class, model = User_SysInfoModel.class)
@CygQuerys({
        @CygQuery(name = "_equal_id", query = "equal_id", type = Integer.class),
})
public class User_SysInfoService extends BaseService {
    @Autowired
    UserDao userDao;
    @Autowired
    UserInRoleDao userInRoleDao;
    @Autowired
    UserService userService;
    @Autowired
    UserDaoHelper userDaoHelper;
    @Autowired
    UserInRoleDaoHelper userInRoleDaoHelper;
    @Autowired
    UserOptions userOptions;
    @Autowired
    DeptDaoHelper deptDaoHelper;
    @Autowired
    UserCustomConvertor userCustomConvertor;
    @Autowired
    User_SysInfoService user_sysInfoService;
    @Autowired
    CompanyDaoHelper companyDaoHelper;

    @Autowired
    Global global;

    //region javadoc注释 : putByUserId
    /**
     * 管理员更新管辖范围下的用户的系统信息 <br/><br/>
     * 简介&nbsp;:&nbsp;更新用户的系统信息 <br/>
     * 步骤&nbsp;: <br/>
     * 1.&nbsp;验证角色的合法性&nbsp;: <br/>
     * &nbsp;根据登录用户的companyId查询公司(COMPANY)company_1, <br/>
     * &nbsp;如果company_1.type为燃气公司，body.firstRoleId只能为1或2，否则抛出异常201； <br/>
     * &nbsp;如果company_1.type为物联网设备公司，body.firstRoleId只能为3或4，否则抛出异常201； <br/>
     * 2.&nbsp;查询用户&nbsp;: <br/>
     * &nbsp;根据路径参数userId查询登录用户管辖范围下的用户(USER)user_1，筛选条件：user_1.id&nbsp;=&nbsp;userId <br/>
     * &nbsp;如果user_1不存在，抛出异常202； <br/>
     * 3.&nbsp;验证新的部门编号的合法性&nbsp;: <br/>
     * &nbsp;如果body.deptId&nbsp;!=&nbsp;user_1.deptId，则根据body.deptId查询登录用户管辖范围内的部门(DEPT)dept_1，如果dept_1不存在，抛出异常203； <br/>
     * 4.&nbsp;更新用户信息&nbsp;: <br/>
     * &nbsp;根据body更新user_1的相关属性，并同时设置以下属性： <br/>
     * &nbsp;(1)&nbsp;user_1.userCode&nbsp;=&nbsp;dept_1.resourceCode； <br/>
     * &nbsp;(2)&nbsp;user_1.resourceCode&nbsp;=&nbsp;dept_1.resourceCode； <br/>
     * 5.&nbsp;更新用户角色&nbsp;: <br/>
     * &nbsp;根据user_1.id查询用户角色关系(USER_IN_ROLE)，筛选出roleId值最小的那个用户角色关系(USER_IN_ROLE)userInRole_1， <br/>
     * &nbsp;如果userInRole_1存在，则设置属性：userInRole_1.roleId&nbsp;=&nbsp;body.firstRoleId <br/>
     * 6.&nbsp;返回信息&nbsp;: <br/>
     * &nbsp;根据条件参数查询更新结果，组装响应并返回； <br/>
     * @param header <br/>
     * _token : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 令牌;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-user-id : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 用户编号;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/>
     * _hzhr-user-code : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 用户代码;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-user-name : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 用户名;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-company-id : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 公司编号;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/>
     * _hzhr-dept-id : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 部门编号;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/>
     * _hzhr-user-type : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 用户类型(关联: common_service.options.code, typeCode = 'USER_TYPE');<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-transaction-id : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 交易流水号;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-transaction-type : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 交易类型;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-access-mode : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 访问模式 0:一般 1:全局;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 默认值 : 0;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/><br/>
     * @param query <br/>
     * _show : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 展示形式 one:展示一个,list:展示列表,null(空值):不展示;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _show_info : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 是否展示详情;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 默认值 : false;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : boolean;<br/><br/>
     * @param userId 用户编号 <br/><br/>
     * @param body <br/><br/>
     * @throws ServiceException <br/>
     * @see User_SysInfoPutModel body <br/>
     * @see User_SysInfoGetModel result <br/>
     */ 
    //endregion
    //region 说明 : putByUserId
    //管理员更新管辖范围下的用户的系统信息
    //简介 : 更新用户的系统信息
    //步骤 :
    //1. 验证角色的合法性 :
    // 根据登录用户的companyId查询公司(COMPANY)company_1,
    // 如果company_1.type为燃气公司，body.firstRoleId只能为1或2，否则抛出异常201；
    // 如果company_1.type为物联网设备公司，body.firstRoleId只能为3或4，否则抛出异常201；
    //2. 查询用户 :
    // 根据路径参数userId查询登录用户管辖范围下的用户(USER)user_1，筛选条件：user_1.id = userId
    // 如果user_1不存在，抛出异常202；
    //3. 验证新的部门编号的合法性 :
    // 如果body.deptId != user_1.deptId，则根据body.deptId查询登录用户管辖范围内的部门(DEPT)dept_1，如果dept_1不存在，抛出异常203；
    //4. 更新用户信息 :
    // 根据body更新user_1的相关属性，并同时设置以下属性：
    // (1) user_1.userCode = dept_1.resourceCode；
    // (2) user_1.resourceCode = dept_1.resourceCode；
    //5. 更新用户角色 :
    // 根据user_1.id查询用户角色关系(USER_IN_ROLE)，筛选出roleId值最小的那个用户角色关系(USER_IN_ROLE)userInRole_1，
    // 如果userInRole_1存在，则设置属性：userInRole_1.roleId = body.firstRoleId
    //6. 返回信息 :
    // 根据条件参数查询更新结果，组装响应并返回；
    //endregion
    //region 参数 : putByUserId
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "令牌",required = true, dataType = "string", paramType = "header"),

            @ApiImplicitParam(name = "userId", value = "用户编号",required = true, dataType = "int", paramType = "path"),

            @ApiImplicitParam(name = "show", value = "展示形式 one:展示一个,list:展示列表,null(空值):不展示", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "show_info", value = "是否展示详情", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),

    })
    @ApiImplicitInternalParams({
            @ApiImplicitParam(name = "_token", value = "令牌",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-id", value = "用户编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-code", value = "用户代码",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-name", value = "用户名",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-company-id", value = "公司编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-dept-id", value = "部门编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-type", value = "用户类型(关联: common_service.options.code, typeCode = 'USER_TYPE')",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-id", value = "交易流水号",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-type", value = "交易类型",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-access-mode", value = "访问模式 0:一般 1:全局",defaultValue = "0", required = false, dataType = "int", paramType = "header"),

            @ApiImplicitParam(name = "_show", value = "展示形式 one:展示一个,list:展示列表,null(空值):不展示", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_show_info", value = "是否展示详情", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),

    })


    //endregion
    //region 请求 : putByUserId
    @RequestMapping(value = "/users/{userId}/sys-infos", method = RequestMethod.PUT)
    //endregion
    @Transactional(rollbackFor = Exception.class)
    public User_SysInfoGetModel putByUserId(Map<String, String> header, Integer userId,
                                            Map<String, Object> query, User_SysInfoPutModel body) throws ServiceException {
        /* 验证角色的合法性 */
        String gasCompanyCode = userOptions.getCode(UserOptionsTypeName.COMPANY_TYPE, UserOptionsName.COMPANY_TYPE.GAS_COMPANY);//1
        String iotDeviceCompanyCode =  userOptions.getCode(UserOptionsTypeName.COMPANY_TYPE, UserOptionsName.COMPANY_TYPE.IOT_DEVICE_COMPANY);//2
        UserCardModel userCardModel = getUserCard(header);
        CompanyEntity company_1 = companyDaoHelper.getById(userCardModel.getCompanyId());
        String type = company_1.getType();
        if (gasCompanyCode.equals(type)) {
            if (body.getFirstRoleId()!=1 && body.getFirstRoleId()!=2)
                throw new ServiceException(User_ErrorsEnum.USER_SYSINFOSERVICE_PUT_BY_ID_201);
        }
        if (iotDeviceCompanyCode.equals(type)) {
            if (body.getFirstRoleId()!=3 && body.getFirstRoleId()!=4)
                throw new ServiceException(User_ErrorsEnum.USER_SYSINFOSERVICE_PUT_BY_ID_201);
        }

        /*查询用户*/
        UserEntity user_1 = userDaoHelper.getByIdAndResourceCode(userId, userCardModel.getUserCode() + "%");
        if (user_1 == null) {
            throw new ServiceException(User_ErrorsEnum.USER_SYSINFOSERVICE_PUT_BY_ID_202);
        }

        /* 验证新的部门编号的合法性 */
        DeptEntity dept_1 = null;
        if (body.getDeptId() != user_1.getDeptId()){
            dept_1 = deptDaoHelper.getByIdAndResourceCode(body.getDeptId(),userCardModel.getUserCode());
            if (dept_1 == null){
                throw new ServiceException(User_ErrorsEnum.USER_SYSINFOSERVICE_PUT_BY_ID_203);
            }
        }

        /*更新用户信息*/
        user_1.setType(userCardModel.getType());
        user_1.setUpdateTime(new Date());
        if (dept_1 != null) {
            user_1.setUserCode(dept_1.getResourceCode());
            user_1.setResourceCode(dept_1.getResourceCode());
        }
        user_1.setUpdateUserId(userCardModel.getUserId());
        int changeCount = userDao.update(user_1);

        /*更新用户角色 */
        UserInRoleEntity userInRole_1 = userInRoleDaoHelper.getByUserIdAndOrderByRoleId(user_1.getId(),"ASC");
        if (userInRole_1 != null){
            userInRole_1.setRoleId(body.getFirstRoleId());
            userInRoleDao.update(userInRole_1);
        }

        /*返回信息*/
        query.put("_equal_id", user_1.getId());
        User_SysInfoGetModel result = user_sysInfoService.get(initHeader(header,AccessModeEnum.GLOBAL),query);
        result.setChangeCount(changeCount);
        return result;
    }

    //region javadoc注释 : get
    /**
     * 管理员查询其管辖范围下的用户的系统信息 <br/><br/>
     * 简介&nbsp;:&nbsp;查询用户的系统信息 <br/>
     * 步骤&nbsp;: <br/>
     * 1.&nbsp;查询用户&nbsp;:&nbsp;(√) <br/>
     * &nbsp;根据条件参数查询用户(USER)； <br/>
     * 2.&nbsp;返回信息&nbsp;:&nbsp;(√) <br/>
     * &nbsp;根据条件参数和查询到的结果组装响应并返回； <br/>
     * @param header <br/>
     * _token : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 令牌;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-user-id : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 用户编号;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/>
     * _hzhr-user-code : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 用户代码;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-user-name : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 用户名;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-company-id : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 公司编号;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/>
     * _hzhr-dept-id : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 部门编号;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/>
     * _hzhr-user-type : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 用户类型(关联: common_service.options.code, typeCode = 'USER_TYPE');<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-transaction-id : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 交易流水号;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-transaction-type : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 交易类型;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-access-mode : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 访问模式 0:一般 1:全局;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 默认值 : 0;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/><br/>
     * @param query <br/>
     * _show : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 展示形式 one:展示一个,list:展示列表,null(空值):不展示;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _show_info : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 是否展示详情;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 默认值 : false;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : boolean;<br/>
     * _page : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 页数;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 默认值 : 1;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/>
     * _count : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 每页数量;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 默认值 : 1;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/>
     * _equal_id : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 筛选条件 : where user_sysInfo.id = #{equal_id};<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/><br/>
     * @throws ServiceException <br/>
     * @see User_SysInfoGetModel result <br/>
     */ 
    //endregion
    //region 说明 : get
    //管理员查询其管辖范围下的用户的系统信息
    //简介 : 查询用户的系统信息
    //步骤 :
    //1. 查询用户 : (√)
    // 根据条件参数查询用户(USER)；
    //2. 返回信息 : (√)
    // 根据条件参数和查询到的结果组装响应并返回；
    //endregion
    //region 参数 : get
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "令牌",required = true, dataType = "string", paramType = "header"),

            @ApiImplicitParam(name = "show", value = "展示形式 one:展示一个,list:展示列表,null(空值):不展示", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "show_info", value = "是否展示详情", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "page", value = "页数", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "count", value = "每页数量", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "equal_id", value = "筛选条件 : where user_sysInfo.id = #{equal_id}",required = false, dataType = "int", paramType = "query"),

    })
    @ApiImplicitInternalParams({
            @ApiImplicitParam(name = "_token", value = "令牌",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-id", value = "用户编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-code", value = "用户代码",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-name", value = "用户名",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-company-id", value = "公司编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-dept-id", value = "部门编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-type", value = "用户类型(关联: common_service.options.code, typeCode = 'USER_TYPE')",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-id", value = "交易流水号",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-type", value = "交易类型",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-access-mode", value = "访问模式 0:一般 1:全局",defaultValue = "0", required = false, dataType = "int", paramType = "header"),

            @ApiImplicitParam(name = "_show", value = "展示形式 one:展示一个,list:展示列表,null(空值):不展示", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_show_info", value = "是否展示详情", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "_page", value = "页数", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_count", value = "每页数量", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_equal_id", value = "筛选条件 : where user_sysInfo.id = #{equal_id}",required = false, dataType = "int", paramType = "query"),

    })

    //endregion
    //region 请求 : get
    @RequestMapping(value = "/users/sys-infos", method = RequestMethod.GET)
    //endregion
    public User_SysInfoGetModel get(Map<String, String> header, Map<String, Object> query) throws ServiceException {
        /* 查询用户 */
        //生成查询模型
        UserCustomQueryModel queryModel = userCustomConvertor.user_SysInfoService_query2queryModel(query);
        queryModel.setEqual_isValid(CommonOptions.YES_NO.YES);
        //查询实体
        List<UserEntityExt> extList = null;
        String show = HzhrTypeUtil.object2string(query.get("_show"));
        if (!StringUtils.isEmpty(show)) {
            extList = userDao.selectExtList(queryModel);
        }
        //查询数量
        Integer total = null;
        Boolean showTotal = HzhrTypeUtil.object2boolean(query.get("_show_total"));
        if (showTotal) {
            total = userDao.selectCount(queryModel);
        }

        /* 返回信息 */
        User_SysInfoGetModel result = userCustomConvertor.extList2user_SysInfoGetModel(extList, total, null, query);
        return result;
    }
}








































































































